<template>
  <el-dialog :title="title" :visible.sync="open" width="50%" @close="closeForm" append-to-body>
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="用户名称:" prop="name">
        <span>{{form.name}}</span>
      </el-form-item>
      <el-form-item label="身份证号:" prop="idNo">
        <span>{{form.idNo}}</span>
      </el-form-item>
      <el-form-item label="检查项目:" prop="testItem">
        <span>{{form.testItem?testItemOptionsObj[form.testItem] :''}}</span>
      </el-form-item>
      <el-form-item label="联系方式:" prop="phone">
        <span>{{form.phone}}</span>
      </el-form-item>
      <el-form-item label="性别:" prop="sex">
        <span>{{form.sex=='male'?'男':'女'}}</span>
      </el-form-item>
      <el-form-item label="年龄:" prop="age">
        <span>{{form.age}}</span>
      </el-form-item>
      <el-form-item label="识别码:" prop="sampleNo">
        <img :src="sampleNoSrc+form.sampleNo" alt="" style="height:100px; width: 312px;">
        <a style="display: inline-block;vertical-align: top" target="_blank" :href="'/qrcode.html?sampleNo=' + form.sampleNo"><span>打印</span></a>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
import {   formShowBarCode } from "@/api/singera/applyForm";
export default {
  name: "userView",
  data(){
    return{
      // 弹出层标题
      title: "查看用户",
      // 是否显示弹出层
      open: false,
      // 表单参数
      form: {},
      sampleNoSrc: process.env.VUE_APP_BASE_API  +'/form/showBarCode/',
      testItemOptionsObj: {}


    }
  },
  methods: {
    init(params){
      this.open = true
      this.form = params.row
      this.testItemOptionsObj = params.testItemOptionsObj
      // this.sampleNoSrc = this.showCode



    },
    closeForm(){
      this.open = false
      this.$emit('viewUserFormClose')
    },
    // showCode(code){
    //   formShowBarCode({text:code}).then(response => {
    //     this.sampleNoSrc = "data:image/gif;base64," + response;
    //   });
    // }
  }
}
</script>

<style scoped>
::v-deep .el-dialog__header{
  border-bottom: 1px solid #ddd;
  text-align: center;
}
</style>
